﻿Public Class ctrTraCuuHD

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        frmMain.TabControl1.TabPages.Remove(frmMain.TabControl1.SelectedTab)
    End Sub

    Private Sub ctrTraCuuHD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        gvHoaDon_Load()
        gvChiTietHD_Load()
    End Sub

    Private Sub gvHoaDon_Load()
        Dim bus As GeneralBUS = New GeneralBUS()
        gvHoaDon.DataSource = bus.GetTable("select MaHD, TongTien, ThoiGian from HOADON where TinhTrangTT=True")
    End Sub

    Private Sub gvChiTietHD_Load()
        Dim bus As GeneralBUS = New GeneralBUS()
        gvChiTietHD.DataSource = bus.GetTable("select CT.MaHD, TenMon, SoLuong, ThanhTien" _
                                              & " from CHITIETHOADON CT, HOADON HD, THUCDON TD" _
                                              & " where TD.MaMon=CT.MaMon and CT.MaHD=HD.MaHD and HD.MaHD=" + gvHoaDon.CurrentRow.Cells(0).Value.ToString())
    End Sub

    Private Sub btnTimKiem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimKiem.Click
        Dim bus As GeneralBUS = New GeneralBUS()
        gvHoaDon.DataSource = bus.GetTable("select * from HOADON where ThoiGian>=#" + dtBatDau.Text + "# and ThoiGian<=#" + dtKetThuc.Text + "# and TinhTrangTT=True")
    End Sub

    Private Sub gvHoaDon_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gvHoaDon.SelectionChanged
        gvChiTietHD_Load()
    End Sub
End Class
